package com.example.trans.controller;

import com.example.trans.service.LogInfoService;
import com.example.trans.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserInfoService userInfoService;
    @Autowired
    private LogInfoService logInfoService;
    @Transactional(propagation = Propagation.REQUIRED)
    @RequestMapping("/register")
    public Boolean register(String userName, String password){
        Integer result = userInfoService.insertUserInfo(userName, password);
        System.out.println("插入用户表, result:" + result);
        Integer logResult = logInfoService.insert(userName, "用户注册");
        return true;
    }
}
